package com.sunny.ynhz.adapter;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sunny.ynhz.R;
import com.sunny.ynhz.bean.RecentNewsBean;
import com.sunny.ynhz.ui.daily.news.DetailActivity;
import com.sunny.ynhz.utils.TimeFormatUtils;

import java.util.List;

/**
 * Created by luao on 2017/7/25.
 */

public class RecentNewsAdapter extends BaseQuickAdapter<RecentNewsBean.DataBean,BaseViewHolder> {
    public RecentNewsAdapter(@Nullable List<RecentNewsBean.DataBean> data) {
        super(R.layout.item_recent_news,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final RecentNewsBean.DataBean item) {
        helper.setText(R.id.title,item.getDescribe());
        helper.setText(R.id.time, TimeFormatUtils.getTime(item.getTime(),"MM-dd"));
        helper.setText(R.id.addr,item.getPosition());

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext,DetailActivity.class);
                intent.putExtra("problem",item);
                intent.putExtra("problemId",item.getProblemid());
                mContext.startActivity(intent);
            }
        });
    }
}
